package summer_vacation.yangyiqing.m201508;
import java.util.Scanner;

/**
 * Created by Administrator on 2015/8/17 0017.
 */
public class Java_18 {
    public static void main(String[] args){
        System.out.println("请输入n（n为杨辉三角的行数）：");
        Scanner s=new Scanner(System.in);
        final int n=s.nextInt();
        //ʹ�ö�ά�������
        int arrays[][]=new int[n+1][];
        for(int i=0;i<=n;i++){
            arrays[i]=new int[i+1];
        }
        //����������
        System.out.println("该杨辉三角是：");
        yangHuiSanjiao(arrays,n);
    }
    public static void yangHuiSanjiao(int arrays[][],int n) {
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j < arrays[i].length; j++) {
                if (i == 0 || j == 0 || j == arrays[i].length - 1)
                    arrays[i][j] = 1;
                else arrays[i][j] = arrays[i - 1][j - 1] + arrays[i - 1][j];

            }
        }
        //��ӡ�������
        for(int i=0;i<=n;i++){
            for(int j=0;j<arrays[i].length;j++){
                System.out.printf(arrays[i][j]+" ");
            }
            System.out.println();
        }
    }
}
